# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=tlstunnel
pkgver=0.1.4
pkgrel=3
pkgdesc="TLS reverse proxy"
url="https://sr.ht/~emersion/tlstunnel/"
license="MIT"
arch="all"
depends="ca-certificates"
makedepends="go scdoc libcap"
subpackages="$pkgname-doc $pkgname-openrc"
pkgusers="$pkgname"
pkggroups="$pkgname"
install="$pkgname.pre-install"
source="$pkgname-v$pkgver.tar.gz::https://git.sr.ht/~emersion/tlstunnel/archive/v$pkgver.tar.gz
	$pkgname.initd
	config
	"
builddir="$srcdir/tlstunnel-v$pkgver"

export GOFLAGS="$GOFLAGS -trimpath -mod=readonly -modcacherw"
export GOPATH="$srcdir"

build() {
	make GOFLAGS="$GOFLAGS"
}

check() {
	go test ./...
}

package() {
	make DESTDIR="$pkgdir" PREFIX=/usr BINDIR=/usr/sbin install
	setcap cap_net_bind_service=+ep "$pkgdir"/usr/sbin/tlstunnel

	install -Dm644 "$srcdir"/config "$pkgdir"/etc/tlstunnel/config

	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
}

sha512sums="
85e4548e174f939109d68a508470124bf7c7ade068f8d78a7e6bfcd6889cc727bef54c1435ad4fda60e3946438b118784028c37600a35ddf9e2ff45c00856053  tlstunnel-v0.1.4.tar.gz
fd781358eb5fd1c1605b9330e0094108d758d9e9664e99a451ba5a58a52f68a4858cd2b6b75fcb3aeec05a81b72758ca49c1f18e6e3ecebe01ccf655ad53d3cc  tlstunnel.initd
a4ec6c1ff057b9ad5d9e9294725dbc03f937669da30956c33c11da86f8122740eb9d4989e7dd0ad3032e7351e8bf1f8fa4d2320771aa24d227ff766d20c05258  config
"
